package com.wy.powerbuilder.service.impl.ld;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wy.powerbuilder.entity.ld.User;
import com.wy.powerbuilder.mapper.ld.UserMapper;
import com.wy.powerbuilder.service.ld.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

@Service
public class UserServiceimpl implements UserService
{
    @Autowired
    private UserMapper userMapper;
    @Override
    public User getUser(String name) {
        return userMapper.getUser(name);
    }

    @Override
    public Set<String> getMenu(String name) {
        return userMapper.getMenu(name);
    }

    @Override
    public PageInfo<User> pageAll(Integer pageNo,String u_userName) {
        if(pageNo==null){
            pageNo=1;
        }
        PageHelper.startPage(pageNo,6);
        System.out.println(u_userName);
        List<User> users=userMapper.all(u_userName);
        PageInfo<User> pageInfo=new PageInfo<>(users);
        return pageInfo;
    }

    @Override
    public Integer upState(User user) {
        return userMapper.upState(user);
    }

    @Override
    public Integer delUser(Integer id) {
        return userMapper.delUser(id);
    }

    @Override
    public Integer addAdmin(User user) {
        return userMapper.addAdmin(user);
    }

    @Override
    public User showUser(int id) {
        return userMapper.showUser(id);
    }

    @Override
    public Integer updateAdmin(User user) {
        return userMapper.updateAdmin(user);
    }
}
